package com.xiaomaoguai.cxf.demo1;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;

/**
 * @Description :
 * @FileName: Client.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年8月17日 下午1:58:21
 * @Version:V1.00
 */
public class Client {

	private static final QName SERVICE_NAME = new QName("http://demo1.cxf.xiaomaoguai.com/", "HelloService");
	private static final QName PORT_NAME = new QName("http://demo1.cxf.xiaomaoguai.com/", "HelloServicePort");

	private Client() {
	}

	public static void main(String args[]) throws Exception {
		Service service = Service.create(SERVICE_NAME);
		// Endpoint Address
		String endpointAddress = "http://localhost:9090/helloWorld";

		// Add a port to the Service
		service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);

		HelloService hw = service.getPort(HelloService.class);
		System.out.println(hw.sayHello("World"));

		System.out.println(hw.getUser(new User(1, "kaka")));

		for (User user : hw.getListUser()) {
			System.out.println("List User [id:" + user.getId() + "][name:" + user.getName() + "]");
		}
	}

}
